package com.feicheng.lanniao.controller.pc;

import com.feicheng.lanniao.anno.StaticSelectCountOfCarRentInfo;
import com.feicheng.lanniao.anno.StaticSelectCountOfHouseRentInfo;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.lanniao.entity.CarRentInfo;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.ICarRentInfoService;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@RestController
@RequestMapping("/lanniao-user/car-rent-info")
public class CarRentInfoClientPcController {
	@Autowired
	private ICarRentInfoService icarRentInfoService;

	@GetMapping("/page")
	public ResultInfo search(String title, 
			String details,
			Integer clientId,
			@RequestParam(required = false, defaultValue = "1") Integer currentPage,
			@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
		return icarRentInfoService.RentcarList(title,details,clientId,currentPage, pageSize);
	}

	@DeleteMapping("/info")
	public ResultInfo del(Integer crId) {
		return icarRentInfoService.deleteRent(crId);
	}

	//@StaticSelectCountOfCarRentInfo //切面
	@GetMapping("/info")
	public ResultInfo select(Integer crId) {
		return icarRentInfoService.selectRentCarById(crId);
	}

	@PutMapping("/info")
	public ResultInfo update(CarRentInfo carRentInfo) {
		return icarRentInfoService.updateRent(carRentInfo);
	}

	@PostMapping("/info")
	public ResultInfo add(String tel,String wxNumber,String title,String details,Integer clientId) {
		return icarRentInfoService.addOneRent(tel,wxNumber,title,details,clientId);
	}
}
